//
//  TestReloadTableViewController.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2020/11/10.
//  Copyright © 2020 moon. All rights reserved.
//

#import "TestReloadTableViewController.h"
#import "ReloadMenuTableViewCell1.h"
#import "Menu.h"
#import "TestEmptyTableViewSectionView.h"
#import "ReloadControlTableViewCell.h"
@interface TestReloadTableViewController ()

@end

@implementation TestReloadTableViewController
+ (MKTFuncItem *)funcItem{
    return [MKTFuncItem funcWithName:@"TableView刷新" viewControllerClass:self];
} 
//+ (BOOL)hiddenSectionHeadFootView{
//    return YES;
//}
- (void)viewDidLoad{
    [super viewDidLoad];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    UIBarButtonItem *refreshItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemRefresh) target:self action:@selector(__refresh)];
    self.navigationItem.rightBarButtonItems = @[refreshItem];
    [self.model hideSectionHeadFootView];
    [self __reloadData];
}
- (void)__refresh{
    [self.model reloadTableViewData];
}
- (void)__reloadData{
    [self.model removeAllSectionModels];
    for (int i=0; i<2; i++) {
        for (Menu *m in [Menu sharedMenus]) {
            MKUITableViewSectionModel *sm = [[MKUITableViewSectionModel alloc] init];
//            sm.showHeadView = YES;
//            sm.showFootView = YES;
//            sm.showDefaultFootView = YES;
//            sm.showDefaultHeadView = YES;
//            sm.headViewClass = sm.footViewClass = [TestEmptyTableViewSectionView class];
//            sm.headTitle = @"1";
//            sm.footTitle = @"2";
            [self.model addSectionModel:sm];
            MKUITableViewCellModel *cm = [MKUITableViewCellModel modelWithValue:m];
            cm.cellClass = [ReloadMenuTableViewCell1 class];
            [self.model addCellModel:cm];
        }
        {
            MKUITableViewSectionModel *sm = [[MKUITableViewSectionModel alloc] init];
            [self.model addSectionModel:sm];
            MKUITableViewCellModel *cm = [MKUITableViewCellModel modelWithValue:nil];
            cm.cellClass = [ReloadControlTableViewCell class];
            [self.model addCellModel:cm];
        }
    }
    [self.model reloadTableViewData];
}
@end
